package cn.sczhyt.modules.szhy.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.sczhyt.common.utils.PageUtils;
import cn.sczhyt.common.utils.Query;

import cn.sczhyt.modules.szhy.dao.MeetingUserDao;
import cn.sczhyt.modules.szhy.entity.MeetingUserEntity;
import cn.sczhyt.modules.szhy.service.MeetingUserService;


@Service("meetingUserService")
public class MeetingUserServiceImpl extends ServiceImpl<MeetingUserDao, MeetingUserEntity> implements MeetingUserService {
    @Autowired
    MeetingUserDao meetingUserDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<MeetingUserEntity> page = this.page(
                new Query<MeetingUserEntity>().getPage(params),
                new QueryWrapper<MeetingUserEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public Integer userCount(String meetingId) {

        return meetingUserDao.userCount(meetingId);
    }

    @Override
    public MeetingUserEntity getByMeetingIdAndUserId(String meetingId, String userId) {
        QueryWrapper<MeetingUserEntity> queryWrapper = new QueryWrapper<MeetingUserEntity>()
                .eq("meeting_id",meetingId)
                .eq("meeting_user_id",userId);
        MeetingUserEntity entity = meetingUserDao.selectOne(queryWrapper);
        return entity;
    }

}